import request from "@/utils/request";
import store from "@/store/index";
export function isTenant() {
  return !!store.getters.userInfo.tenantId;
}
function videoContext() {
  return isTenant() ? "/video-video" : "/ttvideo";
}
//服务转移
function videoContextTransfer() {
  return isTenant() ? "/video-stdu" : "/ttvideo";
}
function eventContext() {
  return isTenant() ? "/event" : "/ttevent";
}
function deviceContext() {
  return isTenant() ? "/device" : "/ttdevice";
}

//查询权限
export function selectRoleById(query) {
  return request({
    url: videoContext() + "/video/query/selectRoleById",
    method: "post",
    data: query,
  });
}
//获取视频格式字典表，用于切换
export function getEnumInfo(query) {
  return request({
    url: "/admin/base/system/dict/data/dictType/" + query.enumTypeId,
    method: "get",
  });
}
//分页查询通道录像计划-明细(摄像机管理)
export function queryRecordPlanForPageNew(query) {
  return request({
    url: "ttvideo/video/query/queryRecordPlanForPageNew",
    method: "post",
    data: query,
  });
}
//分页查询通道录像计划-整合(摄像机管理)
export function queryRecordMergePlan(query) {
  return request({
    url: "ttvideo/video/query/queryRecordMergePlan",
    method: "post",
    data: query,
  });
}
//查询转义后PTZ位置
export function queryPtzPositionNew(query) {
  return request({
    url: "/ttvideo/video/query/queryPtzPositionNew",
    method: "post",
    data: query,
  });
}
//查询预置点列表
export function queryPresetList(query) {
  return request({
    url: videoContext() + "/video/query/queryPresetList",
    method: "post",
    data: query,
  });
}
//查询看守位
export function queryGuardList(query) {
  return request({
    url: videoContext() + "/video/query/queryGuardList",
    method: "post",
    data: query,
  });
}
//查询巡航路径
export function queryPatrol(query) {
  return request({
    url: videoContext() + "/video/query/queryPatrol",
    method: "post",
    data: query,
  });
}
//分页查询巡航路径
export function queryPatrolTower(query) {
  return request({
    url: "/ttvideo/video/query/queryPatrolTower",
    method: "post",
    data: query,
  });
}
//分页查询巡航计划
export function queryPatrolPage(query) {
  return request({
    url: videoContext() + "/video/query/queryPatrolPage",
    method: "post",
    data: query,
  });
}
//巡航计划批量开始结束-new
export function batchDoPatrol(query) {
  return request({
    url: videoContext() + "/video/patrol/batchDoPatrol",
    method: "post",
    data: query,
  });
}
//巡航计划批量删除
export function batchDelPatrolNew(query) {
  return request({
    url: videoContext() + "/video/patrol/batchDelPatrolNew",
    method: "post",
    data: query,
  });
}
//启用/停用巡航路径先获取控制权
export function doPatrol(query) {
  return request({
    url: videoContext() + "/video/control/doPatrol",
    method: "post",
    data: query,
  });
}
export function doPatrolNew(query) {
  return request({
    url: "/video-video/video/patrol/doPatrol",
    method: "post",
    data: query,
  });
}
//开始/结束云台转动先获取控制权
export function doPtzCmds(query) {
  return request({
    url: videoContext() + "/video/control/doPtzCmds",
    method: "post",
    data: query,
  });
}
//开始/结束聚焦(focus)/缩放(zoom)
export function doCameraFocusOrZoom(query) {
  return request({
    url: videoContext() + "/video/control/doCameraFocusOrZoom",
    method: "post",
    data: query,
  });
}
//转到指定PTZ位置
export function doPtzLocationCmd(query) {
  return request({
    url: videoContext() + "/video/control/doPtzLocationCmd",
    method: "post",
    data: query,
  });
}
//转到预置点
export function doControlPreset(query) {
  return request({
    url: videoContext() + "/video/control/doControlPreset",
    method: "post",
    data: query,
  });
}
//抓图
export function doControlPresetAndSnapShot(query) {
  return request({
    url: "ttvideo/video/control/doControlPresetAndSnapShot",
    method: "post",
    data: query,
  });
}
export function doSnapShot(query) {
  return request({
    url: "/video-video/video/algorithm/snapShot",
    method: "post",
    data: query,
  });
}
//获取云台控制权
export function doLock(query) {
  return request({
    url: videoContext() + "/video/control/doLock",
    method: "post",
    data: query,
  });
}
//释放云台控制权
export function doRelease(query) {
  return request({
    url: videoContext() + "/video/control/doRelease",
    method: "post",
    data: query,
  });
}
//开启/关闭灯
export function doSwitchLight(query) {
  return request({
    url: videoContext() + "/video/control/doSwitchLight",
    method: "post",
    data: query,
  });
}
//查询通道的录像列表
export function queryVideoList(query) {
  return request({
    url: videoContextTransfer() + "/video/player/queryVideoList",
    method: "post",
    data: query,
  });
}
//获取通道的录像回放流URL地址
export function getVideoPlaybackUrl(query) {
  return request({
    url: videoContextTransfer() + "/video/player/getVideoPlaybackUrl",
    method: "post",
    data: query,
  });
}
//4.12.获取通道实时流URL地址
export function getVideoRealtimeUrl(query) {
  return request({
    url: videoContextTransfer() + "/video/player/getVideoRealtimeUrl",
    method: "post",
    data: query,
  });
}
//定位
export function thirdLocation(query) {
  return request({
    url: videoContext() + "/video/player/thirdLocation",
    method: "post",
    data: query,
  });
}
//6.53.枪球联动
export function doLinkage(query) {
  return request({
    url: "/video-video/arCruisePlan/doLinkage",
    method: "post",
    data: query,
  });
}
//获取语音对讲通道
export function getAudioChannel(query) {
  return request({
    url: videoContextTransfer() + "/video/player/getAudioChannel",
    method: "post",
    data: query,
  });
}
//倍速回放
export function playBackControl(query) {
  return request({
    url: videoContextTransfer() + "/video/player/playBackControl",
    method: "post",
    data: query,
  });
}

//获取用户习惯
export function getUserHabit(query) {
  return request({
    url: videoContext() + "/video/query/getUserHabit",
    method: "post",
    data: query,
  });
}

//设置用户习惯
export function setUserHabit(query) {
  return request({
    url: videoContext() + "/video/query/setUserHabit",
    method: "post",
    data: query,
  });
}

//获取气象数据
export function getWeatherNow(query) {
  return request({
    url: "/order/weather/now",
    method: "post",
    data: query,
  });
}

//获取未来气象数据（查询未来的天气）
export function getWeatherDay(query) {
  return request({
    url: "/order/weather/day",
    method: "post",
    data: query,
  });
}

//获取空气质量
export function getAirNow(query) {
  return request({
    url: "/order/air/now",
    method: "post",
    data: query,
  });
}

//转动到指定经纬度角度
export function turnToPtzByPointAngle(query) {
  return request({
    url: videoContext() + "/video/query/turnToPtzByPointAngle",
    method: "post",
    data: query,
  });
}

//转动到指定经纬度角度
export function turnToPtzByPointAngle2(query) {
  return request({
    url: "/video-video/video/query/turnToPtzByPointAngle2",
    method: "post",
    data: query,
  });
}

//指哪打哪
export function focusThisPoint(query) {
  return request({
    url: "/video-video/video/query/focusThisPoint",
    method: "post",
    data: query,
  });
}

//指北针
export function getCompass(query) {
  return request({
    url: "/video-video/video/query/getCompass",
    method: "post",
    data: query,
  });
}
//获取设备标签
export function queryVideoDetail(query) {
  let url = "/video/queryVideoDetail";
  if (isTenant()) {
    url = "/video/device/queryDeviceForWE";
  }
  return request({
    url: deviceContext() + url,
    method: "post",
    data: query,
  });
}
//新增/修改雨天模式告警压制配置
export function saveSuppressConfig(query) {
  return request({
    url: "/event/alarm/suppress/saveOrUpdateConfig",
    method: "post",
    data: query,
  });
}
//删除雨天模式告警压制配置
export function deleteSuppressConfig(deviceCode) {
  return request({
    url: "/event/alarm/suppress/delete/" + deviceCode,
    method: "delete",
  });
}
//查询雨天模式告警压制配置
export function querySuppressConfig(deviceCode) {
  return request({
    url: "/event/alarm/suppress/querySuppressConfig/" + deviceCode,
    method: "get",
  });
}
// 简约模式-批量查询抓图
export function getSnapShotSimple(query) {
  return request({
    url: "/video-video/video/player/getSnapShotSimple",
    method: "post",
    data: query,
  });
}
//根据客户、通道、设备查询算法配置列表（不分页）
export function queryAlgorithm(query) {
  return request({
    url: deviceContext() + "/video/algorithm/queryAlgorithm",
    method: "post",
    data: query,
  });
}
//查询指定通道下所有告警压制区域的查询接口(租户)
export function queryAreaSuppressList(query) {
  return request({
    url: eventContext() + "/alarm/suppressStrategy/queryAreaSuppressList",
    method: "post",
    data: query,
  });
}
//通过告警压制区域ID查询告警压制区域详情信息接口(租户)
export function queryAreaSuppress(query) {
  return request({
    url: eventContext() + "/alarm/suppressStrategy/queryAreaSuppress",
    method: "post",
    data: query,
  });
}
//铁塔--查询区域树具体设备
export function queryDevicesByAreaParam(query) {
  return request({
    url: "/ttdevice/video/queryDevicesByAreaParam",
    method: "post",
    data: query,
  });
}
//铁塔--查询区域树具体设备部分数据
export function queryPartDevicesByAreaParam(query) {
  return request({
    url: "/ttdevice/video/queryDevicesByAreaParamForAll",
    method: "post",
    data: query,
  });
}

//铁塔--根据设备编码查设备、通道信息
export function queryDevicesChannelInfo(query) {
  return request({
    url: "/ttdevice/video/reservePlan/queryDevicesChannelInfo",
    method: "post",
    data: query,
  });
}
//铁塔--查询组织树具体设备
export function queryDevicesByDeptParam(query) {
  return request({
    url: "/ttdevice/ttview/device/queryDevicesByDeptParam",
    method: "post",
    data: query,
  });
}
//铁塔--查询标签树具体设备
export function queryDevicesByLabelParam(query) {
  return request({
    url: "/ttdevice/video/queryDevicesByLabelParam",
    method: "post",
    data: query,
  });
}
//铁塔--收藏
export function addOrCancelCollections(query) {
  return request({
    url: "/ttdevice/ttview/device/addOrCancelCollections",
    method: "post",
    data: query,
  });
}
//查询正在锁定云台的人
export function queryPlatFormLockInfo(query) {
  return request({
    url: "/video-video/video/control/queryPlatFormLockInfo",
    method: "post",
    data: query,
  });
}
//新增前端告警
export function saveBeforeAlarm(query) {
  return request({
    url: "/device/algorithm/give/save",
    method: "post",
    data: query,
  });
}
//新增后端算法
export function saveAfterAlgorithm(query) {
  return request({
    url: "/device/video/algorithm/save",
    method: "post",
    data: query,
  });
}
//根据算法查询置信度
export function getAlgorithmInfoBatch(query) {
  return request({
    url: "/device/video/algorithm/getAlgorithmInfoBatch",
    method: "post",
    data: query,
  });
}
//前端算法详情查询
export function queryBeforeAlarmById(query) {
  return request({
    url: "/device/algorithm/give/queryById/" + query,
    method: "get",
  });
}
//后端算法详情查询
export function queryAfterAlgorithmById(query) {
  return request({
    url: "/device/video/algorithm/queryById",
    method: "post",
    data: query,
  });
}
//后端算法下拉框列表
export function queryAlgorithmList(query) {
  return request({
    url: "/device/video/algorithm/queryAlgorithmList",
    method: "post",
    data: query,
  });
}
//记忆接口
export function uptUserMemoryInfo(query) {
  return request({
    url: "/video-video/video/uptUserMemoryInfo",
    method: "post",
    data: query,
  });
}
//读取记忆接口
export function getUserMemoryInfo(query) {
  return request({
    url: "/video-video/video/getUserMemoryInfo",
    method: "post",
    data: query,
  });
}
//查询网格
export function getGrid(query) {
  return request({
    url: "/bdm/grid/getMessageByLngLatNew",
    method: "post",
    data: query,
  });
}
//查询网格员
export function getGridKeeper(query) {
  return request({
    url: "/bdm/gridKeeper/search",
    method: "post",
    data: query,
  });
}
//查询预置位下历史告警信息、图片、视频
export function getOrderListImg(query) {
  return request({
    url: eventContext() + "/alarm/order/getOrderListByDeviceChannelAndPresetId",
    method: "post",
    data: query,
  });
}
//查询预置位下历史告警信息详情
export function getOrderInfoForPreset(query) {
  return request({
    url: eventContext() + "/alarm/order/getOrderInfo",
    method: "post",
    data: query,
  });
}

export function getPresetImgJob(query) {
  return request({
    url: "/video-video/video/patrol/queryPresetImgJob",
    method: "post",
    data: query,
  });
}
// 根据设备id数组获取天气信息
export function getWeatherInfo(params) {
  return request({
    url: "/video-video/arTagsInfo/weatherInfoList",
    method: "post",
    data: params,
  });
}
// 获取标签关联告警数据
export function getRelatedAlarm(params) {
  return request({
    url: eventContext() + "/alarm/order/getOrderListByDeviceChannelAndPresetId",
    method: "post",
    data: params,
  });
}

// 获取标签告警数据
export function getRelatedAlarmPoint(params) {
  return request({
    url:
      eventContext() +
      "/alarm/order/getOrderListByDeviceChannelAndPresetIdGroup",
    method: "post",
    data: params,
  });
}
// 电子围栏查询
export function queryPolygonPatchShow(params) {
  return request({
    url: "/device/polygonPatch/queryPolygonPatchShow",
    method: "post",
    data: params,
  });
}
// 校验该摄像机是否有有效参考点
export function pointsValid(params) {
  return request({
    url: "/video-video/video/query/pointsValid",
    method: "post",
    data: params,
  });
}
// 通过播放窗口百分比点转地图经纬度
export function turnLatitudeByPoint(params) {
  return request({
    url: "/event/alarm/order/turnLatitudeByPoint",
    method: "post",
    data: params,
  });
}
// 通过播放窗口百分比点测高度
export function getCameraCoord(params) {
  return request({
    url: "/event/alarm/order/getCameraCoord",
    method: "post",
    data: params,
  });
}
// 查询图斑信息
export function getXjxlFeaturesByIds(params) {
  return request({
    url: "/gis/getFeatures/getXjxlFeaturesByIds",
    method: "post",
    data: params,
  });
}
// 物联设备数据监测
export function getSensorData(params) {
  return request({
    url: "/device/iotDeviceConfig/getSensorData",
    method: "post",
    data: params,
  });
}
// 查询图斑信息
export function getLayerTypeAttrFilter(params) {
  return request({
    url: "/bdm/layer/getLayerTypeAttrFilter",
    method: "post",
    data: params,
  });
}
// 查询通道列表
export function getChannelsByDeviceCode(params) {
  let url = "/video/device/getChannelsByDeviceCode";
  if (isTenant()) {
    url = "/video/device/getChannelInfoForCustomer";
  }
  return request({
    url: deviceContext() + url,
    method: "post",
    data: params,
  });
}
// 通过deviceCode 拉流
export function getVideoRealtimeUrlInfo(params) {
  return request({
    url: "/device/video/device/getVideoRealtimeUrlInfo",
    method: "post",
    data: params,
  });
}
